package com.example.winner.progressdialog;

import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Button;
import android.view.View.OnClickListener;

public class MainActivity extends AppCompatActivity {
    private ProgressBar first=null;
    private ProgressBar second=null;
    private Button bt=null;
    private int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        first=(ProgressBar)findViewById(R.id.firstBar);
        second=(ProgressBar)findViewById(R.id.secondBar);
        bt=(Button)findViewById(R.id.myButton);
        bt.setOnClickListener(new ButtonListener());
    }
    class ButtonListener implements OnClickListener
    {
        @Override
        public void onClick(View view)
        {
            if(i==0)
            {
                first.setVisibility(View.VISIBLE);
                second.setVisibility(View.VISIBLE);
                first.setMax(150);
            }
            else if(i<first.getMax())
            {
                first.setProgress(i);
                first.setSecondaryProgress(i+10);
            }
            else
            {
                first.setVisibility(View.GONE);
                second.setVisibility(View.GONE);
            }
            i=i+10;
        }
    }
}
